<?php
class JoinController extends Agitum_Controller_Action
{
	public function init() {}

	public function indexAction()
	{
		$form = $this->_helper->formLoader('register');
        if($this->getRequest()->isPost()){
            if(!$form->isValid($_POST)){
                $this->view->form = $form;
                return;
            }
        }
        $this->view->form = $form;
	}

	public function validateAction()
	{
		$this->_helper->viewRenderer->setNoRender();
		$this->_helper->layout()->disableLayout();

		$form = $this->_helper->formLoader('register');
		$form->isValid($this->_request->getPost());
		$json = $form->getMessages();

		$this->_response->setHeader('Content-Type', 'application/json');
		echo Zend_Json::encode($json);
	}

}